package com.echo.protocol;

import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger;

public class MessageProtocol {
    private static final AtomicInteger ID = new AtomicInteger();
    private int reqId;
    private int len;
    private byte[] content;

    public MessageProtocol() {
        reqId = ID.getAndIncrement();
    }

    public MessageProtocol(int reqId, int len, byte[] content) {
        this.reqId = reqId;
        this.len = len;
        this.content = content;
    }
//    public MessageProtocol(int len, byte[] content) {
//        this.len = len;
//        this.content = content;
//    }

    public int getReqId() {
        return reqId;
    }

    public MessageProtocol(int reqId) {
        this.reqId = reqId;
    }

    public int getLen() {
        return len;
    }

    public void setLen(int len) {
        this.len = len;
    }

    public byte[] getContent() {
        return content;
    }

    @Override
    public String toString() {
        return "MessageProtocol{" +
                "reqId=" + reqId +
                ", len=" + len +
                ", content=" + Arrays.toString(content) +
                '}';
    }

    public void setContent(byte[] content) {

        this.content = content;
    }
}
